Como retornar o nome do mês se no banco está registrado como date?

Nome título mês date

Utilizo case e extract month na query.

Por exemplo:

SELECT Case EXTRACT(month FROM data)
                        when '1' then 'Janeiro'
                        when '2' then 'Fevereiro'
                        when '3' then 'Março'
                        when '4' then 'Abril'
                        when '5' then 'Maio'
                        when '6' then 'Junho'
                        when '7' then 'Julho'
                        when '8' then 'Agosto'
                        when '9' then 'Setembro'
                        when '10'then 'Outubro'
                        when '11'then 'Novembro'
                        when '12'then 'Dezembro'
                        else NULL
                        end as nome_mes,
                        EXTRACT(month FROM data) AS mes,
                        EXTRACT(year FROM data) AS ano,
                        FROM tabela;

O extract pega parte da data que pode ser o ano, mês ou dia.

O case uso para comparar os 12 meses e inserir o título dele.

Quer acompanhar as novidade do site?

Leia mais em: ocs.oracle.com/cd/B19306_01/s...

Como retornar o nome do mês se no banco está registrado como date?

Última atualização: 2023-02-15

Palavras-Chaves